﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using JBeamLibrary.Tools;
using JBeamLibrary.VehicleParts.Enums;
using JBeamLibrary.VehicleParts.Interfaces;
using Newtonsoft.Json.Linq;

namespace JBeamLibrary.VehicleParts.Elements
{
    public class Hydro : VehicleElement
    {
        #region Properties

        public string NodeId1 { get; set; }

        public string NodeId2 { get; set; }

        #endregion

        #region CTORs

        public Hydro()
        {
        }

        public Hydro(string id1, string id2)
            : this()
        {
            NodeId1 = id1;
            NodeId2 = id2;
        }

        #endregion

        #region Methods

        public override IVehicleElement FromJBeam(JToken token)
        {
            var arr = token as JArray;
            if (arr == null) return this;

            NodeId1 = token[0].FromJBeam<string>();
            NodeId2 = token[1].FromJBeam<string>();

            return this;
        }

        public override JToken ToJBeam()
        {
            return new JArray { NodeId1.ToJBeam(), NodeId2.ToJBeam() };
        }

        public override string ToString()
        {
            return string.Format("({0},{1})", NodeId1, NodeId2);
        }

        #endregion
    }
}
